/*!
 * \file __frproto_mng_key.c
 *
 * All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.\n
 *
 * \version 3.0
 * \author geyh
 * \date 2016/03/31
 *
 */
#include <CUnit/Basic.h>
#include <stdlib.h>

#include "frcomm.h"
#include "frmem.h"
#include "frlist.h"
#include "frproto_mng.h"
#include "apmtest_cunit.h"

#include "apmtest_comm.h"

static int __suite_init(void)
{
//    frmodule_mng_init();
    return 0;
}

static int __suite_cleanup(void)
{
//    frmodule_mng_destory();
    return 0;
}


int __frproto_mng_key(int i_ip_proto, u_int ui_ip, char *p_key, unsigned int ui_key_size);

static void __case1(void)
{
    int i_ret = 0;
    int i_ip_proto = 6;
    u_int ui_ip = iptools_parse_ipaddr((char *)"192.168.1.1");
    char *p_key = NULL;
    unsigned int ui_key_size = 8;

    p_key = (char *)frmalloc(ui_key_size);
    memset(p_key, 0x00, ui_key_size);

    i_ret = __frproto_mng_key(i_ip_proto, ui_ip, p_key, ui_key_size);

    CU_ASSERT_EQUAL(i_ret,0);

    frfree(p_key);
    return;

}

static void __case2(void)
{
    int i_ret = 0;
    int i_ip_proto = 6;
    u_int ui_ip = iptools_parse_ipaddr((char *)"192.168.1.1");
    char *p_key = NULL;
    unsigned int ui_key_size = 9;

    p_key = (char *)frmalloc(ui_key_size);
    memset(p_key, 0x00, ui_key_size);

    i_ret = __frproto_mng_key(i_ip_proto, ui_ip, p_key, ui_key_size);

    CU_ASSERT_EQUAL(i_ret,8);

    frfree(p_key);
    return;

}



int add_suite___frproto_mng_key(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite("frproto_mng __frproto_mng_key()", __suite_init, __suite_cleanup)) == NULL)
        return FR_FAIL;

    CU_add_test(pSuite, "case1", __case1);
    CU_add_test(pSuite, "case2", __case2);
//    CU_add_test(pSuite, "case3", __case3);
//    CU_add_test(pSuite, "case4", __case4);
//    CU_add_test(pSuite, "case5", __case5);

    return FR_SUCC;
}
